﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tank.Role;

namespace Tank
{
    public class Data
    {
        /// <summary>
        /// 当前游戏状态
        /// </summary>
        public static GameState indexState = GameState.StartFrame;

        /// <summary>
        /// 当前选择坦克状态
        /// </summary>
        public static selectTankState indexselectTankState = selectTankState.OnePlay;

        /// <summary>
        /// 游戏状态
        /// </summary>
        public enum GameState
        {
            /// <summary>
            /// 开始画面
            /// </summary>
            StartFrame = 0,
            /// <summary>
            /// 游戏画面
            /// </summary>
            GameFrame,
            /// <summary>
            /// 游戏结束
            /// </summary>
            GameOver,
            /// <summary>
            /// 游戏设置
            /// </summary>
            GameSet
        }

        /// <summary>
        /// 选择坦克的位置
        /// </summary>
        public enum selectTankState
        {
            /// <summary>
            /// 一个玩家
            /// </summary>
            OnePlay = 0,
            /// <summary>
            /// 两个玩家
            /// </summary>
            TwoPlay,
            /// <summary>
            /// 编辑地图
            /// </summary>
            EditMap
        }

        /// <summary>
        /// 获取选择坦克向下一个位置
        /// </summary>
        /// <returns></returns>
        public static selectTankState getNextSelectTankState()
        {
            try
            {
                int index = (int)indexselectTankState;
                if (indexselectTankState == selectTankState.EditMap)
                    return indexselectTankState;
                else
                    return (selectTankState)(++index);
            }
            catch
            {
                return indexselectTankState;
            }
        }

        /// <summary>
        /// 获取选择坦克向上一个位置
        /// </summary>
        /// <returns></returns>
        public static selectTankState getLastSelectTankState()
        {
            try
            {
                int index = (int)indexselectTankState;
                if (indexselectTankState == selectTankState.OnePlay)
                    return indexselectTankState;
                else
                    return (selectTankState)(--index);
            }
            catch
            {
                return indexselectTankState;
            }
        }

        /// <summary>
        /// 每个格子大小
        /// </summary>
        public static int GridSize = 20;

        /// <summary>
        /// 坦克放大倍数，取值范围1~2
        /// </summary>
        public static float TankEnlarge = 1.5f;

        /// <summary>
        /// 地图资源
        /// </summary>
        public enum mapImage
        {
            /// <summary>
            /// 砖墙
            /// </summary>
            wall = 1,
            /// <summary>
            /// 金刚墙
            /// </summary>
            steel,//
            /// <summary>
            /// 草地
            /// </summary>
            grass,//
            /// <summary>
            /// 水
            /// </summary>
            water//
        }

        /// <summary>
        /// 当前关卡
        /// </summary>
        public static int indexCheckpoint = 1;

        /// <summary>
        /// 方向
        /// </summary>
        public enum Direction
        {
            /// <summary>
            /// 上
            /// </summary>
            up,
            /// <summary>
            /// 下
            /// </summary>
            down,
            /// <summary>
            /// 左
            /// </summary>
            left,
            /// <summary>
            /// 右
            /// </summary>
            right
        }

        /// <summary>
        /// 时间轴 玩家是否可以移动 true可以移动
        /// </summary>
        public static bool playerMove = false;

        /// <summary>
        /// 时间轴 NPC是否可以移动 true可以移动
        /// </summary>
        public static bool NPCMove = false;

        /// <summary>
        /// 时间轴 子弹是否可以移动 true可以移动
        /// </summary>
        public static bool BulletMove = false;

        /// <summary>
        /// 时间轴 刷新时间 单位毫秒
        /// </summary>
        public static int timeAxis = 50;

        /// <summary>
        /// npc每颗子弹间隔时间 =3秒/timeAxis
        /// 
        ///  判断发送子弹，一颗子弹没有消失不可以发送第二颗，且每颗子弹间隔一定时间
        /// </summary>
        public static int NPcSendBulleTime = 60;//默认3秒

        /// <summary>
        /// 游戏暂停 true暂停
        /// </summary>
        public static bool isStop = false;

        /// <summary>
        /// 每次移动像素大小
        /// </summary>
        public const int MoveSize = 3;

        /// <summary>
        /// 玩家
        /// </summary>
        public enum play
        {
            /// <summary>
            /// 玩家1
            /// </summary>
            one,
            /// <summary>
            ///  玩家2
            /// </summary>
            two
        }

        /// <summary>
        /// 玩家集合
        /// </summary>
        public static List<Player> playList = new List<Player>();

        /// <summary>
        /// npc种类
        /// </summary>
        public enum NPCType
        {
            /// <summary>
            /// 1
            /// </summary>
            one,
            /// <summary>
            /// 2
            /// </summary>
            two,
            /// <summary>
            /// 3
            /// </summary>
            three
        }

        /// <summary>
        /// NPC集合
        /// </summary>
        public static List<NPC> NPCList = new List<NPC>();

        /// <summary>
        /// 子弹类型
        /// </summary>
        public enum BulletType
        {
            /// <summary>
            /// npc子弹
            /// </summary>
            NpcBullet,
            /// <summary>
            /// 玩家子弹
            /// </summary>
            PlayBullet
        }

        /// <summary>
        /// 子弹集合
        /// </summary>
        public static List<Bullet> BulletList = new List<Bullet>();

        /// <summary>
        /// 当前from的句柄
        /// </summary>
        public static IntPtr indexFrmIntPtr;

        /// <summary>
        /// 所有地图
        /// </summary>
        public static List<MapData> MapDatas = new List<MapData>();
    }
}
